//
//  JCClubFindCell.m
//  SquashSpark
//
//  Created by 郭吉成 on 2017/11/23.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "JCClubFindCell.h"
#import "JCClubModel.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "NSAttributedString+RichText.h"

@interface JCClubFindCell ()

@property (weak, nonatomic) IBOutlet UILabel *rankLabel;
@property (weak, nonatomic) IBOutlet UIImageView *clubIcon;
@property (weak, nonatomic) IBOutlet UILabel *clubNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *durationLabel;
@property (weak, nonatomic) JCClubModel *model;

@end

@implementation JCClubFindCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self.clubIcon clipsCornerRadius:4];
}

- (void)setClubModel:(JCClubModel *)model indexPath:(NSIndexPath *)indexPath{
    _model = model;
    _rankLabel.text = @(indexPath.row+1).stringValue;
    [_clubIcon sd_setImageWithURL:model.headIcon placeholderImage:kPlaceholdImage];
    _clubNameLabel.text = model.name;
    _addressLabel.text = [model.address stringByAppendingString:[NSString stringWithFormat:@" · %@ players",model.memberCount]];
    
    _durationLabel.attributedText = [NSAttributedString attriWithSeconds:model.duration.integerValue * 60 hAndMFont:kOpenSansFont(OpenSansRegular, 11) numberFont:kOpenSansFont(OpenSansRegular, 16) textColor:kTWhiteText];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
